# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=gcompat
pkgver=0.9.0
pkgrel=0
pkgdesc="The GNU C Library compatibility layer for musl"
url="https://code.foxkit.us/adelie/gcompat"
arch="all"
options="!check" # No test suite
license="NCSA"
makedepends="libucontext-dev musl-obstack-dev"
replaces="libc6-compat"
source="https://distfiles.adelielinux.org/source/gcompat/gcompat-$pkgver.tar.xz"

case "$CARCH" in
	armel) _ld="ld-linux.so.3" ;;
	armhf | armv7) _ld="ld-linux-armhf.so.3" ;;
	aarch64) _ld="ld-linux-aarch64.so.1" ;;
	x86) _ld="ld-linux.so.2" ;;
	x86_64) _ld="ld-linux-x86-64.so.2" ;;
	mips* | s390*) _ld="ld.so.1" ;;
	ppc64le) _ld="ld64.so.2" ;;
esac

build() {
	make \
		WITH_LIBUCONTEXT=1 \
		WITH_OBSTACK=musl-obstack \
		LINKER_PATH="/lib/ld-musl-$CARCH.so.1" \
		LOADER_NAME="$_ld"
}

package() {
	make \
		LINKER_PATH="/lib/ld-musl-$CARCH.so.1" \
		LOADER_NAME="$_ld" \
		WITH_LIBUCONTEXT=1 \
		WITH_OBSTACK=musl-obstack \
		DESTDIR="$pkgdir" \
		install
}

sha512sums="d19a1b450f84de80579ce562946ad3da155fa50c2c0642f4b94c8ec22517151493852888455f6d813529816d7518468ec7b5178bb536514045596700fd05738c  gcompat-0.9.0.tar.xz"
